<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:include="layout :: htmlhead" th:with="title='用户管理'"></head>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" th:href="@{res/login.css}">
    <!--<style type="text/css">
        .mainbody{
            background-color: #555555;
        }
        .container{
            width: 420px;
            height: 260px;
            min-height: 260px;
            max-height: 260px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }
        .close{
            background-color: white;
            border: none;
            font-size: 18px;
            margin-left: 410px;
            margin-top: -10px;
        }

        .layui-input{
            border-radius: 5px;
            width: 300px;
            height: 40px;
            font-size: 15px;
        }
        .layui-form-item{
            margin-left: -20px;
        }
        #logoid{
            margin-top: -20px;
            margin-left: 100px;
            padding-bottom: 25px;
            font-size: 20px;
            font-family: 'Times New Roman';
            font-weight: bold;
        }
        .layui-btn{
            margin-left: -50px;
            border-radius: 5px;
            width: 350px;
            height: 40px;
            font-size: 15px;
        }
        .verity{
            width: 120px;
        }
        .font-set{
            font-size: 13px;
            text-decoration: none;
            margin-left: 120px;
        }
        a:hover{
            text-decoration: underline;
        }

    </style>-->
</head>
<body class="mainbody">
<form class="layui-form" action="" method="post">
    <div class="container">
        <!--<button class="close" title="关闭">X</button>-->
        <div class="layui-form-mid layui-word-aux">
            <div class="layui-form-item">
                <label id="logoid">CIM软件统一发布平台</label>
            </div>
        </div>
        <input type="hidden" name="id" autocomplete="off" class="layui-input">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密 &nbsp;&nbsp;码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">登陆</button>
            </div>
        </div>
    </div>
</form>
<!--
<script type="text/javascript" th:src="@{layui/layui.js}"></script>
-->
<script>
    layui.use(['form','jquery'], function(){
        var form = layui.form
            ,layer = layui.layer
        var $ = layui.$;
        //监听提交
        form.on('submit(formDemo)', function(data){
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })*/
            $.ajax({
                url:'user/login',
                type:'post',
                dataType:'JSON',
                contentType: 'application/json;charset=UTF-8',
                data: JSON.stringify(data.field),
                async: true,
                success: function(data){
                    console.log(data);
                    if(data.msg == 'success'){
                        layer.msg("登录成功");
                        location.href = "admin"
                    }else{
                        layer.msg("登录失败")
                    }
                },
                error:function () {
                    layer.msg("登录失败")
                }
            })

            return false;
        });


    });
</script>
</body>
</html>